interface Worker{
    fun  work()
    fun takeVocation()
    fun fileTimeSheet() = println("Why? Really?")
}

interface Assistant{
    fun doChroes()
    fun fileTimeSheet() = println("No escape from that")
}
class JavaProgrammer:Worker{
    override fun work() {
        println(".....write java....")
    }

    override fun takeVocation() {
        println(".....code at beach....")
    }
}

class CSharpProgrammer:Worker{
    override fun work() {
        println(".....write C#....")
    }

    override fun takeVocation() {
        println(".....relaxing at beach....")
    }
}

//class Manager() :Worker by JavaProgrammer()
class Manager() :Worker by CSharpProgrammer()

/*val javaProgrammer = JavaProgrammer()
javaProgrammer.work()
javaProgrammer.takeVocation()*/

val manager = Manager()
manager.work()
manager.takeVocation()

class BetterManager(val staff:Worker):Worker by staff{
    fun meeting(){
        println("organizing meeting with ${staff.javaClass.simpleName}")
    }
}
val javaProgrammerXiaoliu  = JavaProgrammer()

val betterManager = BetterManager(javaProgrammerXiaoliu)
betterManager.work()
betterManager.takeVocation()
betterManager.meeting()

//处理方法冲突

class NormalManager(val staff:Worker):Worker by staff{
    override fun takeVocation() {
        println("Of course")
    }
}
val doe = NormalManager(CSharpProgrammer())
doe.work()
println(doe.staff)
println(doe.takeVocation())

class DepartmentAssistant :Assistant{
    override fun doChroes() {
        println("routine staff")
    }
}

class BothManager(val staff:Worker,val assistant:Assistant):Worker by staff,Assistant by assistant{
    override fun takeVocation() {
        println("of course")
    }

    override fun fileTimeSheet() {
        println("manually forwading this.....")
        super<Assistant>.fileTimeSheet()
    }
}

val bManager = BothManager(CSharpProgrammer(),DepartmentAssistant())
bManager.work()
bManager.takeVocation()
bManager.doChroes()
bManager.fileTimeSheet()